<template>
  <!-- 待办待阅 -->
  <div class="todoToread">
    <van-nav-bar title="待办待阅" left-arrow @click-left="onClickLeft" />
    <van-tabs v-model="active" color="#4D98FF" swipe-threshold="3" title-active-color="#4D98FF" @click="handleTab">
      <van-tab title="待办工单" name="0">
        <todo active="0" :key="'todo-' + active" v-if="active === '0'" />
      </van-tab>
      <van-tab title="已办工单" name="1">
        <todo active="1" :key="'todo-' + active" v-if="active === '1'" />
      </van-tab>
      <van-tab title="待阅工单" name="5">
        <todo active="5" :key="'todo-' + active" v-if="active === '5'" />
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import todo from './todo'
import store from '@/store/'
import { showZwtNav } from '@/utils/showNav.js'
const UA = window.navigator.userAgent.toLowerCase()
import { setDefaultGrid } from "@/utils/util"
export default {
  name: 'todoToread',
  components: { todo },
  data() {
    return {
      active: '0',
    }
  },

  mounted() {
    if (sessionStorage.getItem('actives')) {
      this.active = sessionStorage.getItem('actives')
    } else {
      this.active = '0'
    }
    showZwtNav(this.$route.meta.title)
  },
  methods: {
    onClickLeft() {
      // this.$router.push({
      //   path: '/publicline',
      // })
      if (sessionStorage.getItem('isSso') == 'true') {
        setDefaultGrid() // 设置默认网格
      } else {
        if (process.env.NODE_ENV == 'production') {
          const isZWT = UA && /ipumobile/.test(UA)
          if (isZWT) {
            window.WadeMobile && window.WadeMobile.closeH5()
            return
          }
          boncAppEngine.shutdown()
          this.$open('/publicline/index')
        } else {
          this.$open('/publicline/index')
        }
      }

      store.commit('SET_ISACTIVE', null)
      sessionStorage.removeItem('actives')

    },
    handleTab(name) {
      sessionStorage.removeItem('actives')
      this.active = name
      store.commit('SET_ISACTIVE', null)
      sessionStorage.setItem('actives', this.active)
    },
  },
}
</script>
<style lang="less" scoped>
/deep/ .van-nav-bar {
  position: fixed;
  width: 100%;
}

/deep/ .van-tabs__wrap {
  position: fixed;
  width: 100%;
  margin-top: 46px;
  z-index: 9;
}

/deep/ .van-nav-bar__content {
  background: linear-gradient(134deg, #80d9f9 0%, #5466fa 100%);
}

/deep/ .van-nav-bar__title {
  font-size: 18px;
  color: #ffffff;
  letter-spacing: -0.6px;
  text-align: center;
}

/deep/ .van-nav-bar .van-icon {
  color: #fff;
  font-size: 20px;
}

/deep/ .van-tabs__line {
  width: 20px;
  margin-bottom: 3px;
}

/deep/ .van-tabs__nav--line {
  margin-bottom: 10px
}

/deep/ .van-tab__text {
  font-size: 15px;
  color: #333333;
  letter-spacing: -0.53px;
}
</style>